FROM centos:7.2.1511


# 添加用户
RUN useradd --uid=1000 user-dev
# 安装常用工具
RUN yum -y groupinstall "Development Tools"
RUN rpm --rebuilddb && yum -y install vim wget net-tools git sudo
RUN sed -i '93iuser-dev    ALL=(ALL)       NOPASSWD:ALL' /etc/sudoers

#安装php
RUN yum -y remove php*
RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
RUN yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

# nginx
RUN rpm --rebuilddb && yum -y install nginx

# compsoer
RUN curl -sS https://getcomposer.org/installer | php && \
    mv composer.phar /usr/local/bin/composer

RUN rpm --rebuilddb && yum -y install libpng12.x86_64 0:1.2.50-10.el7 libpng12-devel.x86_64 0:1.2.50-10.el7

USER user-dev
# nvm node npm
RUN wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.1/install.sh | bash
RUN source ~/.bashrc && nvm install v8.11.1
# yarn
RUN sudo wget https://dl.yarnpkg.com/rpm/yarn.repo -O /etc/yum.repos.d/yarn.repo && \
    sudo yum -y install yarn

USER root
# 安装mongo扩展
RUN rpm --rebuilddb && yum -y install php72w-pear && pecl install mongodb
# 安装分词扩展
RUN wget http://www.xunsearch.com/scws/down/scws-1.2.3.tar.bz2 && \
    tar xvjf scws-1.2.3.tar.bz2 && \
    cd scws-1.2.3 && \
    ./configure --prefix=/usr/local/scws && \
    make && \
    make install
RUN cd scws-1.2.3/phpext && phpize && \
    ./configure --with-scws=/usr/local/scws --with-php-config=/usr/bin/php-config && \
    make && make install

RUN cd /usr/local/scws/etc && \
    wget http://www.xunsearch.com/scws/down/scws-dict-chs-utf8.tar.bz2 && \
    tar xvjf scws-dict-chs-utf8.tar.bz2 && \
    rm scws-dict-chs-utf8.tar.bz2


COPY init.sh /
COPY phpconf/php.ini /etc/php.ini
COPY phpconf/www.conf /etc/php-fpm.d/www.conf
COPY nginx/nginx.conf /etc/nginx/nginx.conf
RUN chmod -R 777 /var/lib/nginx


USER user-dev
WORKDIR /data
#CMD ["nginx", "-g", "daemon off;"]
CMD ["/init.sh"]





